

version 15
capture log close
set more off
clear
clear matrix
clear mata

if c(username)=="WB485280" {
		glo rootdir		"C:\Users\wb485280\OneDrive - WBG\radicalization"
		}
if c(username)=="WB382635" {
		glo rootdir		"C:\Users\wb382635\Dropbox\Unemp & daesh"
		}
if c(username)=="WB452275" {
		glo rootdir		"C:\Users\WB452275\Dropbox\Projects\Unemp & daesh"
		}
if c(username)=="sarurchaudhary" {
		glo rootdir		"/Users/sarurchaudhary/Dropbox/Unemp & daesh"
		}
if c(username)=="kartikabhatia" {
			glo rootdir		"/Users/kartikabhatia/Dropbox/Before2019/Unemp & daesh"
			}
			
		glo	datadir     "${rootdir}/Data/Raw data"
		glo outdir		"${rootdir}/Data/Working datasets"
		glo dodir		"${rootdir}/Dofiles"
        
			
			cd "${outdir}"
			
* ------------------------------------------------------------------------------

* Date : March 2021 [Checked Oct 2021]

* Project : Daesh FF Working Paper (The World Bank)

* This is the do file for Table 6 in the main paper

* ------------------------------------------------------------------------------
				
	
/****************************************************************************************/
// Table 6: Foreign Recruitment into Daesh - Using Travel Cost Instead of Distance
/****************************************************************************************/

// SAME TABLES AS IN THE MAIN PAPER, BUT REPLACING GEO DISTANCE BY TICKET PRICE

                   	
		use "${outdir}/finaldata_CE.dta", clear 
		
		*drop if inlist(countryname, "Jordan", "Iran, Islamic Rep.","Saudi Arabia", "Kuwait","Lebanon","Turkey","Palestine")
		
		data_preamble //Invoking data prep program to clean data and create variables
						
			
		local key "mnp" // this changes the price variable that is used, it can be mnp mdp min max
			
			
		//Altering variable labels
		la var unemp_log_`key'             "\textbf{Interaction between unemployment and}\\Distance to Syria (log)"

	    global unresc_all ="log_dist_tosyria log_gdp_pc log_pop_muslim_pew log_pop_tot political_rights corruption_index"
	    global resc_fe  ="unemp_log_`key' unemp_log_visa unemp_resc_loggdp unemp_resc_logmuslimpop unemp_resc_logpop_tot unemp_resc_politicalrts unemp_resc_corruption"
        global options1 ="dec(3) nocons word se lab nor2"
		global sortlist ="ilo2_unemp_educ log_ilo2_pop log_wage1lag3 log_wage2lag3 log_wage2lag6 $unresc_all unemp_secondary unemp_tertiary $resc_fe unemp_median_`key'1 unemp_median_`key'2 unemp_tercile_`key'1 unemp_tercile_`key'2 unemp_tercile_`key'3 unemp_quart_`key'1 unemp_quart_`key'2 unemp_quart_`key'3 unemp_quart_`key'4 unemp_log_visa"
		global drop_resc="ctrydummy1-ctrdummy168 educ2 educ3 1b.education_level#co.ilo2_unemp_educ  o.resc_corruption_index o.resc_log_pop_tot o.ilo2_unemp_educ o.hdi o.gini o.resc_political_rights o.resc_fraction_language o.resc_fraction_religion o.resc_fraction_ethnic o.resc_log_pop_muslim_pew o.log_dist_tosyria o.resc_log_gdp_pc"
		
		g unemp_log_visa=ilo2_unemp_educ*visa_free
		label var unemp_log_visa "\textbf{Interaction between unemployment and}\\Visa-Free Entry to Turkey"
				
*********** Table with different splits **************	
		cap drop sample

		*Continuous interaction
		global options2  ctitle("$ log N_{ce}$","Total") nonotes 
		
	*Column 1
		xtreg logn_educ  log_ilo2_pop ilo2_unemp_educ  unemp_log_`key' educ2 educ3 ,  fe vce(cluster ctry)  
		cap drop sample
		gen sample = e(sample)
		mean nisis_educ if e(sample) // should be only for countries close to Syria
		local mean=int(_b[nisis_educ]*10)/10
		xtreg logn_educ  log_ilo2_pop ilo2_unemp_educ  unemp_log_`key' educ2 educ3 , fe vce(cluster ctry)  		
		local clust= e(N_clust)
		areg logn_educ  log_ilo2_pop ilo2_unemp_educ  unemp_log_`key' educ2 educ3 , absorb(ctry)  vce(cluster ctry)  
		local adjr =int(e(r2_a)*100)/100
		local adjr : di %3.2g `adjr'
		xtreg logn_educ   log_ilo2_pop ilo2_unemp_educ  unemp_log_`key' educ2 educ3 , fe vce(cluster ctry)  
		outreg2 using distinteract_price_paper.docx  , tex(frag) $options1 $options2 noni sortvar($sortlist)  drop ($drop_resc ctrydummy*) replace  addtext("Mean $ N_{ce} $", `mean', "Mean $ NF_{ce} $",  x, "Mean $ NS_{ce} $", x, "Mean $ NA_{ce} $",x , Country FE, Y, Number of countries, `clust', Education Dummies, Y, Adj. R-squared, `adjr') 

		*Median- split for Total
		global options2  ctitle("$ log N_{ce}$","Total") nonotes 
		
	*Column 2
		xtreg logn_educ  log_ilo2_pop unemp_median_`key'1 unemp_median_`key'2 educ2 educ3 ,  fe vce(cluster ctry)  
		mean nisis_educ if e(sample) // should be only for countries close to Syria
		local mean=int(_b[nisis_educ]*10)/10
		xtreg logn_educ  log_ilo2_pop unemp_median_`key'1 unemp_median_`key'2 educ2 educ3 , fe vce(cluster ctry)  		
		local clust= e(N_clust)
		areg logn_educ  log_ilo2_pop unemp_median_`key'1 unemp_median_`key'2 educ2 educ3 , absorb(ctry)  vce(cluster ctry)  
		local adjr =int(e(r2_a)*100)/100
		local adjr : di %3.2g `adjr'
		xtreg logn_educ   log_ilo2_pop unemp_median_`key'1 unemp_median_`key'2 educ2 educ3 , fe vce(cluster ctry)  
		outreg2 using distinteract_price_paper.docx  , tex(frag) $options1 $options2 noni sortvar($sortlist)  drop ($drop_resc ctrydummy*) append  addtext("Mean $ N_{ce} $", `mean', "Mean $ NF_{ce} $",  x, "Mean $ NS_{ce} $", x, "Mean $ NA_{ce} $",x , Country FE, Y, Number of countries, `clust', Education Dummies, Y, Adj. R-squared, `adjr') 

		
		*Tercile- split for Total
		global options2  ctitle("$ log N_{ce}$","Total") nonotes 

	*Column 3
		xtreg logn_educ  log_ilo2_pop unemp_tercile_`key'1 unemp_tercile_`key'2 unemp_tercile_`key'3 educ2 educ3 ,  fe vce(cluster ctry)  
		mean nisis_educ if e(sample) // should be only for countries close to Syria
		local mean=int(_b[nisis_educ]*10)/10
		xtreg logn_educ  log_ilo2_pop unemp_tercile_`key'1 unemp_tercile_`key'2 unemp_tercile_`key'3 educ2 educ3 , fe vce(cluster ctry)  		
		local clust= e(N_clust)
		areg logn_educ  log_ilo2_pop unemp_tercile_`key'1 unemp_tercile_`key'2 unemp_tercile_`key'3 educ2 educ3 , absorb(ctry)  vce(cluster ctry)  
		local adjr =int(e(r2_a)*100)/100
		xtreg logn_educ   log_ilo2_pop unemp_tercile_`key'1 unemp_tercile_`key'2 unemp_tercile_`key'3 educ2 educ3 , fe vce(cluster ctry)  
		outreg2 using distinteract_price_paper.docx  , tex(frag) $options1 $options2 noni sortvar($sortlist)  drop ($drop_resc ctrydummy*) append  addtext("Mean $ N_{ce} $", `mean', "Mean $ NF_{ce} $",  x, "Mean $ NS_{ce} $", x, "Mean $ NA_{ce} $",x , Country FE, Y, Number of countries, `clust', Education Dummies, Y, Adj. R-squared, `adjr') 

		*Quartile- split for Total
		global options2  ctitle("$ log N_{ce}$","Total") nonotes
		
	*Column 4
		xtreg logn_educ  log_ilo2_pop unemp_quart_`key'1 unemp_quart_`key'2 unemp_quart_`key'3 unemp_quart_`key'4 educ2 educ3 ,  fe vce(cluster ctry)  
		mean nisis_educ if e(sample) // should be only for countries close to Syria
		local mean=int(_b[nisis_educ]*10)/10
		xtreg logn_educ  log_ilo2_pop unemp_quart_`key'1 unemp_quart_`key'2 unemp_quart_`key'3 unemp_quart_`key'4 educ2 educ3 , fe vce(cluster ctry)  		
		local clust= e(N_clust)
		areg logn_educ  log_ilo2_pop unemp_quart_`key'1 unemp_quart_`key'2 unemp_quart_`key'3 unemp_quart_`key'4 educ2 educ3 , absorb(ctry)  vce(cluster ctry)  
		local adjr=round(e(r2_a),.01)
		local adjr : di %3.2g `adjr'
		xtreg logn_educ   log_ilo2_pop unemp_quart_`key'1 unemp_quart_`key'2 unemp_quart_`key'3 unemp_quart_`key'4 educ2 educ3 , fe vce(cluster ctry)  
		outreg2 using distinteract_price_paper.docx  , tex(frag) $options1 $options2 noni sortvar($sortlist)  drop ($drop_resc ctrydummy*) append  addtext("Mean $ N_{ce} $", `mean', "Mean $ NF_{ce} $",  x, "Mean $ NS_{ce} $", x, "Mean $ NA_{ce} $",x , Country FE, Y, Number of countries, `clust', Education Dummies, Y, Adj. R-squared, `adjr') 
					
	*Column 5 for visa interaction 
		
		*Continuous interaction
		global options2  ctitle("$ log N_{ce}$","Total") nonotes 

		xtreg logn_educ  log_ilo2_pop ilo2_unemp_educ  unemp_log_visa educ2 educ3 ,  fe vce(cluster ctry)  
		cap drop sample
		gen sample = e(sample)
		mean nisis_educ if e(sample) // should be only for countries close to Syria
		local mean=int(_b[nisis_educ]*10)/10
		xtreg logn_educ  log_ilo2_pop ilo2_unemp_educ  unemp_log_visa educ2 educ3 , fe vce(cluster ctry)  		
		local clust= e(N_clust)
		areg logn_educ  log_ilo2_pop ilo2_unemp_educ  unemp_log_visa educ2 educ3 , absorb(ctry)  vce(cluster ctry)  
		local adjr =int(e(r2_a)*100)/100
		local adjr : di %3.2g `adjr'
		xtreg logn_educ   log_ilo2_pop ilo2_unemp_educ  unemp_log_visa educ2 educ3 , fe vce(cluster ctry)  
		outreg2 using distinteract_price_paper.docx  , tex(frag) $options1 $options2 noni sortvar($sortlist)  drop ($drop_resc ctrydummy*) append  addtext("Mean $ N_{ce} $", `mean', "Mean $ NF_{ce} $",  x, "Mean $ NS_{ce} $", x, "Mean $ NA_{ce} $",x , Country FE, Y, Number of countries, `clust', Education Dummies, Y, Adj. R-squared, `adjr') 
		
